package com.zjitc;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/12 15:33
 * @description:
 */
@SuppressWarnings("ALL")
@ComponentScan
@Configuration
public class DataSourceConfig {
  @Bean(name = "DataSource")
  public HikariDataSource dataSource(DataSourceProperties dp) {
    HikariDataSource dataSource = new HikariDataSource();
    dataSource.setUsername(dp.getUsername());
    dataSource.setPassword(dp.getPassword());
    dataSource.setJdbcUrl(dp.getJdbcurl());
    dataSource.setDriverClassName(dp.getDriver());

    return dataSource;
  }
}
